home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 438_01 / stelnet.doc < prev    next >
Encoding:
Text File  |  1994-12-20  |  10.5 KB  |  245 lines

  1. stelnet - A telnet client for the serial port
  2. Version 1.00 (December 20th, 1994)
  3.  
  4. Documentation
  5.  
  6.         Copyright information
  7.  
  8. Copyright 1994 Riku Saikkonen (riku.saikkonen@pcb.compart.fi)
  9.  
  10. This program is free software; you can redistribute and/or modify it
  11. under the terms of the GNU General Public License version 2 as published
  12. by the Free Software Foundation.
  13.  
  14. This program is distributed in the hope that it will be useful, but
  15. WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  17. Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License along
  20. with this program (as the file COPYING); if not, write to the Free
  21. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. The author, Riku Saikkonen, can be contacted via the following means:
  24. E-mail: riku.saikkonen@pcb.compart.fi (preferred) or
  25.         risaikko@freenet.hut.fi
  26. Paper mail: Riku Saikkonen
  27.             Alakartanontie 4 B 63
  28.             SF-02360  ESPOO
  29.             Finland
  30.  
  31.         Description
  32.  
  33. stelnet is a telnet client for MS-DOS, using the serial port (via a FOSSIL
  34. driver) as the I/O device. It was meant for BBS (Bulletin Board System)
  35. use, but works equally well without any BBS software.
  36.  
  37. stelnet supports binary mode telnet (8-bit), and a '8-bit clean mode', in
  38. which all 256 characters are cleanly transferred in both directions.
  39.  
  40. stelnet does not do any terminal emulation of its own; it should never
  41. change the data transferred (except, of course, in IACs and client
  42. commands).
  43.  
  44. stelnet is distributed under the GNU General Public License, version 2, and
  45. thus includes source code.
  46.  
  47.         Features
  48.  
  49. stelnet is a 'conditionally compliant' (in the definition of RFC 1123)
  50. telnet client.
  51.  
  52. The serial port code uses normal FOSSIL interrupts. The 'Read block' and
  53. 'Write block' commands are used for the transfer. The FOSSIL driver is
  54. initialised at the start and deinitialised at the end. stelnet does not
  55. set the bps rate of the port. The program should work with any COM port
  56. supported by the FOSSIL driver.
  57.  
  58. The telnet code uses the Waterloo TCP library (WATTCP), which uses a packet
  59. driver. Any network adapter with a packet driver should work. SLIP should
  60. work, at least with the EtherSLIP packet driver.
  61.  
  62. Telnet options supported are the Binary option, the Echo option, the
  63. Suppress Go Ahead option (stelnet never sends GAs), and the Terminal-Type
  64. option. The terminal type is currently fixed at 'DEC-VT100' in the source;
  65. I will probably make it user-selectable in a future version. stelnet also
  66. sends a couple of VT-100 escape codes to the serial port; search the source
  67. for 'VT-100' for the details. Telnet option negotiation is supported at any
  68. time during the connection. stelnet can send the NVT special codes with
  69. client options.
  70.  
  71. The client options are activated with a user-selectable escape character,
  72. ASCII code 255 by default. The 8-bit clean mode disables this escape
  73. character (and instead passes it through it to the telnet port).
  74.  
  75. Both the telnet and serial ports are double-buffered.
  76.  
  77.         Compiling it yourself
  78.  
  79. The included binary (stelnet.exe) should do well for most applications, but
  80. if you want to compile it yourself for some reason, here's how.
  81.  
  82. First edit the included makefile, especially the paths to your compiler and
  83. the WATTCP library. If you haven't compiled the WATTCP library yet, do it
  84. before compiling stelnet. The makefile looks for the WATTCP library in
  85. ..\lib; I suggest you put stelnet in its own directory under the WATTCP top
  86. directory (e.g. if WATTCP is at c:\wattcp, put stelnet to
  87. c:\wattcp\stelnet). Or change the directory in the definition of CLIB.
  88.  
  89. Then, just execute 'make' and you should have a binary.
  90.  
  91. The default compile-time options (OPTIONS=-D... in the makefile) should
  92. work pretty well for most uses, but if you want to modify them, here is a
  93. description:
  94.  
  95. SIBLEN and TIBLEN are the serial and telnet input buffer sizes, in bytes.
  96. This buffer is always emptied at once (to the output buffers), so the sizes
  97. needn't be very large. Think of the options as specifying the 'chunk size'
  98. for incoming data.
  99.  
  100. SOBLEN and TOBLEN are the sizes of the serial and telnet output buffers,
  101. again in bytes. These are the main buffers of the programs so they should
  102. be a bit larger.
  103.  
  104. SOBLIMIT is kind of a kludge to generate a bit of handshaking into the
  105. telnet protocol. The option simply ceases reading from the telnet
  106. connection if the serial output buffer is almost full (it has SOBLIMIT
  107. bytes or less of free space). It is kind of weird, but it seems to work...
  108. (If anyone knows of a better method for telnet handshaking that preserves
  109. all characters in the input stream (XON/XOFF doesn't), tell me!) Defining
  110. the value to 0 removes the limit, but this usually causes buffer overruns
  111. (and thus lost characters). A good value for the limit is TIBLEN.
  112.  
  113. stelnet runs in a loop, reading and writing as much as it can at every cycle.
  114. Every LOOPCHECK cycles, it checks that the connections are working (carrier
  115. detection, idle timeout, time left, ...). This isn't done on every cycle,
  116. because it would slow the connection down a bit. Every LOOPCHECK*LOOPCHECK
  117. cycles, stelnet displays information about the connection on the local
  118. screen (if the l option is not specified on the command line).
  119.  
  120. There are a few commented-out lines and '!!!' marks in the source code;
  121. these usually signify a slightly kludgy piece of code or a place to add
  122. some feature in the to-do list to.
  123.  
  124. The binary included in the package was compiled using Borland C++ 3.0 and a
  125. version of the WATTCP library from November 14th, 1994. I found a couple of
  126. bugs in the compiler (or at least I couldn't explain a few irregularities
  127. in any other way); the workarounds are detailed in the source (search for
  128. 'BC++ 3.0 bug'). The binary was compiled with the default compile-time
  129. options.
  130.  
  131.         Modifying stelnet
  132.  
  133. Feel free to modify the source code if you wish, but keep the copyright
  134. notices. I would appreciate it if you sent me any added features or bug
  135. reports... I can read the complete new source, a Unix-style 'diff' or 'diff
  136. -u', a human-written difference text, or even an MS-DOS 'fc' output dump.
  137.  
  138.         Executing the program
  139.  
  140. The program syntax is:
  141.     stelnet <comport> <host> <port> [options]
  142. where
  143.     comport = COM port number (1-8)
  144.     host = the host name or IP address to connect to
  145.     port = the TCP/IP port to connect to (23 is the telnet port)
  146.     options = a list of options (as separate arguments)
  147.  
  148. The options:
  149.     t<n> = set a n-minute time limit
  150.     i = set a 5-minute idle timeout
  151.     l = show the connection on the local screen and read the keyboard (this
  152.         currently makes the connection quite slow)
  153.     c = disable Carrier Detect detection on the serial port
  154.     x = don't send telnet/serial initialisation codes (for connecting to
  155.         a finger, NNTP or similar port that does not run telnetd; this
  156.         option disables both the telnet protocol initialisation IACs and
  157.         the VT-100 reset code sent to the serial port)
  158.     8 = enter 8-bit clean mode at the start of the program
  159.     e<code> = set the serial port escape character to ASCII code <code>
  160.       (default 255)
  161.     d<t><filename> = read a door information file:
  162.       <t> = type (see below)
  163.       <filename> = full file name (with a possible path)
  164.       The only type currently defined is p = PCBOARD.SYS.
  165.  
  166. Some examples:
  167.  
  168.     stelnet 1 10.0.0.1 23 t60 i l e33
  169. connects to 10.0.0.1 port 23, using serial port 1, an idle timeout and
  170. showing the connection on the local screen, using '!' (ASCII code 33) as
  171. the escape character.
  172.  
  173.     stelnet 2 hosta.xxx.fi 23 dpc:\pcb\node1\pcboard.sys
  174. connects to hosta.xxx.fi port 23, using serial port 2 and reading
  175. c:\pcb\node1\pcboard.sys as a PCBOARD.SYS-type door file.
  176.  
  177.     stelnet 1 10.0.0.2 79 x
  178. connects to the finger port (port 79) of 10.0.0.2, and does not send the
  179. initialisation codes.
  180.  
  181. The errorlevels stelnet returns are:
  182.   0 = a normal exit
  183.   1 = the user ran out of time (or hit the idle timeout)
  184.   2 = the telnet connection was refused
  185.   3 = a serial port error (initialisation failure, carrier detect lost,
  186.       ...)
  187.   4 = a network error (e.g. name server failure)
  188.   9 = an error in reading the door information file
  189.   10 = an error in the command line
  190.  
  191.         Running the program
  192.  
  193. Anything sent to the serial port is sent to the telnet port, and vice
  194. versa. The only exceptions are the IAC for telnet (which processes telnet
  195. options; an IAC IAC is recognised as an ASCII 255 character and sent to the
  196. serial port) and the client escape character, ASCII 255 by default, for the
  197. serial port.
  198.  
  199. The escape character is used to send special telnet characters and issue
  200. commands to stelnet from the serial port. The user should send the escape
  201. character and the command character following it to the serial port.
  202.  
  203. The client commands are:
  204.  
  205. c Forcefully close the connection and exit stelnet
  206. 8 (in binary mode) Enter 8-bit clean mode. The mode is exited by sending
  207.   the sequence <command key> + <^X> (ASCII 24) + <^X> + "stelnet" (without
  208.   the quotes) to the serial port
  209. i Send telnet Interrupt Process code (IAC IP)
  210. r Send telnet NVT BRK code (IAC BRK)
  211. a Send telnet Abort Output code (IAC AO)
  212. t Send telnet Are You There code (IAC AYT)
  213. e Change the escape character to the next key typed after this command
  214. s Display some status information about stelnet; this does not use the
  215.   telnet STATUS option, which stelnet currently does not support
  216. ? Display a help text of these commands
  217. <escape char> (i.e. press the escape character twice) Send the escape
  218.               character to the telnet port
  219.  
  220.         Bugs, to do
  221.  
  222. See the start of the source code for a list of known bugs and a to-do list.
  223. I accept bugfixes and added features gladly :).
  224.  
  225. See stelnet.bug for a description of one possible bug.
  226.  
  227. If you find a bug, e-mail me about it and I'll try to fix it...
  228.  
  229.         FTP sites
  230.  
  231. stelnet should later be put to the SimTel MS-DOS archive (I hope they'll
  232. accept it :)), probably to the msdos/bbs directory. In the meantime, e-mail
  233. me (my contact information is at the start) for a copy of the latest
  234. version... The filename is stlnt100.zip.
  235.  
  236. The official FTP site for WATTCP is dorm.rutgers.edu: /pub/msdos/wattcp.
  237. Get wattcp.zip there for the newest source for the library.
  238.  
  239. Free packet drivers are in the SimTel archive, e.g. oak.oakland.edu:
  240. /pub/SimTel/msdos/pktdrvr/drivers.zip.
  241.  
  242.         Have fun!
  243.  
  244. End of stelnet.doc.
  245.